package com.capgemini.cn.authority.core.utils;

import org.springframework.aop.support.AopUtils;

/**
 * Created by 2017/9/7
 *
 * @author yaxia
 */
public final class SpringProxyUtils {

    /**
     * 获取 目标对象
     *
     * @param proxy 代理对象
     */
    public static Class getTarget(Object proxy) {
        Class result;

        if (!AopUtils.isAopProxy(proxy)) {  //不是代理对象
            result = proxy.getClass();
        } else {
            result = AopUtils.getTargetClass(proxy);
        }
        return result;
    }
}
